package com.example.exercise.job;

import org.quartz.*;

import java.io.Serializable;
import java.util.Arrays;

public class MyJob1 implements InterruptableJob, Serializable {
    private boolean interruptFlag = false;
    @Override
    public void interrupt() throws UnableToInterruptJobException {
        interruptFlag = true;
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.err.println(interruptFlag);
        JobKey key = jobExecutionContext.getJobDetail().getKey();

        System.err.println(key);
        //使用归并的JobDataMap
        JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();
        System.err.println(Arrays.asList(dataMap.getKeys()));
        System.err.println("定时执行这个任务:MyJob1");
    }
}
